package xyz.robinbingo.effectivejava.chapter03.item10;

import cn.hutool.core.lang.Console;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.net.MalformedURLException;
import java.net.URL;
import java.sql.Timestamp;
import java.util.*;

/**
 * @author Robin
 * @date 2019/03/21 15:33
 **/
@RunWith(SpringRunner.class)
@SpringBootTest
public class Item10 {

    @Test
    public void test00() {
        CaseInsensitiveString cis = new CaseInsensitiveString("Polish");
        String s = "polish";
        Console.log(cis.equals(s));
        Console.log(s.equals(cis));

        List<CaseInsensitiveString> list = new ArrayList<>();
        list.add(cis);
        Console.log(list.contains(s));
    }

    // Initialize unitCircle to contain all Points on the unit
    static final Set<Point> unitCircle = Set.of(
            new Point(1, 0), new Point(0, 1),
            new Point(-1, 0), new Point(0, -1));

    public static boolean onUnitCircle(Point p) {
        return unitCircle.contains(p);
    }

    @Test
    public void test01() {
        final Timestamp a = new Timestamp(100);
        final Date b = new Date(100);
        Console.log(a);
        Console.log(b);
        Console.log(a.equals(b));
        Console.log(b.equals(a));
    }

    @Test
    public void test02() throws MalformedURLException {
        URL url = new URL("a");
        url.equals("a");
    }

    @Test
    public void test03() {
        Console.log(new HashMap<>() instanceof Map);
    }

    @Test
    public void test04() {
        final int compare = Double.compare(0.00000000000000000000001, 0.000000000000000000000011);
        Console.log(compare);
    }
}
